<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>端API</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../script/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
    <style>
        .empty {
            text-align: center;
            padding: 120px 0;
        }

        div.container label {
            font-size: 16px
        }

        div.container button {
            width: 88px;
            height: 45px
        }
    </style>
</head>

<body>
    <div class="container">
        <form>
            <div class="form-group">
                <label for="exampleInputEmail1">请输入题目</label>
                <textarea name="titlecon" class="form-control" rows="3"></textarea>
            </div>
            <div class="form-group">
                <label for="exampleInputPassword2">请输入A答案</label>
                <textarea name="titlea" class="form-control" rows="1"></textarea>
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">请输入B答案</label>
                <textarea name="titleb" class="form-control" rows="1"></textarea>
            </div>
            <div class="form-group">
                <label for="exampleInputPassword4">请输入C答案</label>
                <textarea name="titlec" class="form-control" rows="1"></textarea>
            </div>
            <div class="form-group">
                <label for="exampleInputPassword5">请输入D答案</label>
                <textarea name="titled" class="form-control" rows="1"></textarea>
            </div>
            <div class="radio">
                <label>
      选择正确答案
    </label>
                <br/>
                <label>
       <input type="radio" value="A" name="answer"> 选项A
     </label>
                <label>
       <input type="radio" value="B" name="answer"> 选项B
     </label>
                <label>
       <input type="radio" value="C" name="answer"> 选项C
     </label>
                <label>
       <input type="radio" value="D" name="answer"> 选项D
     </label>
            </div>
            <br/>
            <div class="container">
                <button onclick="getPaper()" type="button" class="btn btn-success">上传试题</button>
            </div>
        </form>
    </div>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/vue.js"></script>
    <script type="text/javascript" src="../script/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="../layer/layer.js"></script>
    <script type="text/javascript" src="../script/init.js" ></script>
    <script type="text/javascript">
    var user = JSON.parse(localStorage.getItem('user'))
    var index=""
        function getPaper() {
            index = layer.load();
            $.ajax({
                url: bashUrl + `title/${user.userid}`,
                type: "post",
                data: $("form").serialize(),
                timeout: 3000,
                dataType: "json",
                success: (data) => {
                    layer.close(index)

                    if(data.meg === "1"){
                      $("textarea").val("")
                      api.toast({
                          msg: "试题加入成功",
                          duration: 2000
                      })
                    }
                },
                error: function() {
                    layer.close(index)
                    api.toast({
                        msg: "请求超时或繁忙",
                        duration: 2000
                    })
                }
            });
        }
    </script>
</body>

</html>
